<style>
.img-ivu-modal .ivu-modal{
  width: 1000px !important;
}
</style>
<template>
<div>
    <Card :bordered="false" dis-hover>
        <!-- 按钮 当前位置-->
        <div class="g_header_nav">
            <div class="g_header_t">
                <div class="operate-btns">
                    <a class="fbtn iconfont icon-head-modify" @click='disabled=false' v-if='false'>修改</a>
                    <a class="fbtn iconfont icon-head-save" @click='save' :disabled="saveDisabled">保存</a>
                    <a class="fbtn iconfont icon-head-release" @click='publish'>发布</a>
                </div>
            </div>
            <div class="con_breadcrumb">
                <ol class="breadcrumb">
                    <li>
                        <router-link to="/front/warehouseEditList">仓库发布列表</router-link>
                    </li>
                    <li>
                        <a href="#">仓库发布编辑</a>
                    </li>
                </ol>
                <h3 class="current_module">仓库发布编辑</h3>
            </div>
        </div>
        <!--end  按钮 当前位置-->
        <!--end头部-->
        <div class="content">
            <form class="layui-form">
                <!-- 基本资料 -->
                <div class="business-info col-md-12">
                    <div class="fheader">
                        <h4 class="fh-tit fh-notes">基本资料</h4>
                        <span class="tips red-tips">*为必填项</span>
                    </div>
                    <div class="fpart pull1">
                        <div class="row">
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex require">
                                    <span class="flexitem">物流中心</span>
                                    <div class="flex1">
                                        <select v-model="detail.LogCenterName">
                                            <option v-for="item in LogCenterList" v-bind:value="item.GUID">
                                                {{ item.ChineseName }}
                                            </option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex require">
                                    <span class="flexitem">仓库名称</span>
                                    <div class="flex1">
                                        <input type="text" v-model="detail.ChineseName" placeholder="">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex require">
                                    <span class="flexitem">联系人</span>
                                    <div class="flex1">
                                        <input type="text" v-model="detail.Contacts" placeholder="">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex require">
                                    <span class="flexitem">联系电话</span>
                                    <div class="flex1">
                                        <input type="text" v-model="detail.ContactTel" placeholder="">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex">
                                    <span class="flexitem">仓库类型</span>
                                    <div class="flex1">
                                        <select v-model="detail.WareHouseType">
                                            <option value="">请选择</option>
                                            <option value="01">平库</option>
                                            <option value="02">高台库</option>
                                            <option value="03">楼库</option>
                                            <option value="04">地下仓库</option>
                                            <option value="05">立体库</option>
                                            <option value="06">坡道库</option>
                                            <option value="07">气体库</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex require">
                                    <span class="flexitem">仓库面积</span>
                                    <div class="flex1">
                                        <input type="number" v-model="detail.TotalAreaAge" placeholder="">
                                    </div>
                                    <i class="flexitem">㎡</i>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex">
                                    <span class="flexitem">可租面积</span>
                                    <div class="flex1">
                                        <input type="number" v-model="detail.CanRentedArea" placeholder="">
                                    </div>
                                    <i class="flexitem">㎡</i>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex require">
                                    <span class="flexitem">起租面积</span>
                                    <div class="flex1">
                                        <input type="number" v-model="detail.Minleasedrea" placeholder="">
                                    </div>
                                    <i class="flexitem">㎡</i>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex">
                                    <span class="flexitem">存储标准</span>
                                    <div class="flex1">
                                        <select v-model="detail.StorageType">
                                            <option value="">请选择</option>
                                            <option value="01">普通仓</option>
                                            <option value="02">恒温仓</option>
                                            <option value="03">冷藏仓</option>
                                            <option value="04">冷冻仓</option>
                                            <option value="05">多温仓</option>
                                            <option value="06">露天堆场</option>
                                            <option value="07">有棚堆场</option>
                                            <option value="08">危化品库</option>
                                            <option value="09">医药库</option>
                                            <option value="10">其他</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex require">
                                    <span class="flexitem">租赁价格</span>
                                    <div class="flex1">
                                        <input type="number" v-model="detail.LeasingPrice" placeholder="">
                                    </div>
                                    <i class="flexitem">元/㎡/月</i>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex">
                                    <span class="flexitem">仓库体积</span>
                                    <div class="flex1">
                                        <input type="number" v-model="detail.TotalVolume" placeholder="">
                                    </div>
                                    <i class="flexitem">m³</i>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex require">
                                    <span class="flexitem">地址</span>
                                    <div class="flex1">
                                        <Cascader :data="ressData" :value.sync="value1" @on-change='venue' size='large' trigger="hover"></Cascader>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-12 col-md-4 col-lg-6">
                                <div class="text-input displayflex">
                                    <span class="flexitem">详细地址</span>
                                    <div class="flex1">
                                        <input type="text" v-model="detail.Address" placeholder="">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 仓库信息编辑 -->
                <div class="cert-info col-md-12">
                    <div class="fheader">
                        <h4 class="fh-tit fh-cert">仓库简介</h4>
                    </div>
                    <div class="fpart pull5">
                        <div class="cert-manage clearfix">
                            <editor @editValue="addParagraph"></editor>
                        </div>
                    </div>
                </div>
                <!-- 基本信息 -->
                <div class="business-info col-md-12">
                    <div class="fheader">
                        <h4 class="fh-tit fh-notes">基本信息</h4>
                    </div>
                    <div class="fpart pull1">
                        <div class="row">
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex">
                                    <span class="flexitem">月台</span>
                                    <div class="flex1">
                                        <select v-model="detail.Platform">
                                            <option value="">不限</option>
                                            <option value="1">无月台</option>
                                            <option value="2">单面月台</option>
                                            <option value="3">双面月台</option>
                                            <option value="4">多面月台</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex">
                                    <span class="flexitem">结构</span>
                                    <div class="flex1">
                                        <select v-model="detail.BuildingStructure">
                                            <option value="">不限</option>
                                            <option value="1">砖瓦混合</option>
                                            <option value="2">轻钢结构</option>
                                            <option value="3">重钢结构</option>
                                            <option value="4">钢混结构</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex">
                                    <span class="flexitem">层高</span>
                                    <div class="flex1">
                                        <select v-model="detail.FloorHeight">
                                            <option value="">不限</option>
                                            <option value="1">6米以下</option>
                                            <option value="2">6-9米</option>
                                            <option value="3">9-12米</option>
                                            <option value="4">12米以上</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 col-lg-3">
                                <div class="text-input displayflex">
                                    <span class="flexitem">消防</span>
                                    <div class="flex1">
                                        <select v-model="detail.FireFighting">
                                            <option value="">不限</option>
                                            <option value="1">无</option>
                                            <option value="2">甲类</option>
                                            <option value="3">乙类</option>
                                            <option value="4">丙类</option>
                                            <option value="5">丁类</option>
                                            <option value="6">戊类</option>
                                            <option value="7">正在办理</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12 col-lg-12">
                                <div class="text-input checkbox-input displayflex">
                                    <span class="flexitem">服务范围</span>
                                    <div class="flex1">
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.ServiceRange2" value="warehouse">
                                            <span><i>仓储</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.ServiceRange2" value="transport">
                                            <span><i>运输</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.ServiceRange2" value="picking">
                                            <span><i>库内作业</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.ServiceRange2" value="process">
                                            <span><i>加工</i></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12 col-lg-6">
                                <div class="text-input checkbox-input displayflex">
                                    <span class="flexitem">安保系统</span>
                                    <div class="flex1">
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.SecuritySystem2" value="monitor">
                                            <span><i>中央监控</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.SecuritySystem2" value="security">
                                            <span><i>保安人员</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.SecuritySystem2" value="patrol">
                                            <span><i>24小时巡逻</i></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12 col-lg-6">
                                <div class="text-input checkbox-input displayflex">
                                    <span class="flexitem">消防系统</span>
                                    <div class="flex1">
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.FireFightingSystem2" value="spray">
                                            <span><i>喷淋</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.FireFightingSystem2" value="smoke">
                                            <span><i>烟感</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.FireFightingSystem2" value="fireHydrant">
                                            <span><i>消防栓</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.FireFightingSystem2" value="fireExtinguisher">
                                            <span><i>灭火器</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.FireFightingSystem2" value="fireAlarm">
                                            <span><i>消防警钟</i></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12 col-lg-12">
                                <div class="text-input checkbox-input displayflex">
                                    <span class="flexitem">库存类别</span>
                                    <div class="flex1 tx12">
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="fastProduct">
                                            <span><i>快消产品</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="device">
                                            <span><i>家用电器</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="office">
                                            <span><i>办公/文仪</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="medical">
                                            <span><i>医疗器械</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="furniture">
                                            <span><i>家具</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="hardware">
                                            <span><i>五金/配件</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="clothes">
                                            <span><i>服饰/鞋帽</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="sport">
                                            <span><i>体育/户外</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="home">
                                            <span><i>家居日用</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="oil">
                                            <span><i>农副/粮油</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="skin">
                                            <span><i>护肤/化妆</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="food">
                                            <span><i>食品/保健</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="drink">
                                            <span><i>酒水/饮料</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="tire">
                                            <span><i>汽配/轮胎</i></span>
                                        </label>
                                        <label class="icon-checkbox">
                                            <input type="checkbox" v-model="detail.GoodsCategory2" value="other">
                                            <span><i>其它原材料</i></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 证照维护 -->
                <div class="cert-info col-md-12">
                    <div class="fheader">
                        <h4 class="fh-tit fh-cert">图片信息</h4>
                    </div>
                    <div class="fpart pull5">
                        <div class="cert-manage clearfix row">
                            <div class="cert-item col-md-3 col-lg-3">
                                <div class="img-box rela-img">
                                    <img :src="warehouseImgs[0].original.url" alt="">
                                </div>
                                <div class="license-btn">
                                    <Upload type="drag" ref="upload" accept="image/*" :data="{position:0}" :action="uploadAction" :on-success="OnUploadSuccess" :on-format-error="handleFormatError" :format="['jpg','jpeg','png']" class="uploadcla">
                                        <span class="iconfont icon-cm-file" title="修改"></span>
                                    </Upload>
                                    <span class="iconfont icon-search" title="放大" @click="handleView(warehouseImgs[0])"></span>
                                    <span class="iconfont icon-dump" title="删除" @click="handleRemove(warehouseImgs[0])"></span>
                                </div>
                            </div>
                            <div class="cert-item col-md-3 col-lg-3">
                                <div class="img-box rela-img">
                                    <img :src="warehouseImgs[1].original.url" alt="">
                                </div>
                                <div class="license-btn">
                                    <Upload type="drag" ref="upload" accept="image/*" :data="{position:1}" :action="uploadAction" :on-success="OnUploadSuccess" :on-format-error="handleFormatError" :format="['jpg','jpeg','png']" class="uploadcla">
                                        <span class="iconfont icon-cm-file" title="修改"></span>
                                    </Upload>
                                    <span class="iconfont icon-search" title="放大" @click="handleView(warehouseImgs[1])"></span>
                                    <span class="iconfont icon-dump" title="删除" @click="handleRemove(warehouseImgs[1])"></span>
                                </div>
                            </div>
                            <div class="cert-item col-md-3 col-lg-3">
                                <div class="img-box rela-img">
                                    <img :src="warehouseImgs[2].original.url" alt="">
                                </div>
                                <div class="license-btn">
                                    <Upload type="drag" ref="upload" accept="image/*" :data="{position:2}" :action="uploadAction" :on-success="OnUploadSuccess" :on-format-error="handleFormatError" :format="['jpg','jpeg','png']" class="uploadcla">
                                        <span class="iconfont icon-cm-file" title="修改"></span>
                                    </Upload>
                                    <span class="iconfont icon-search" title="放大" @click="handleView(warehouseImgs[2])"></span>
                                    <span class="iconfont icon-dump" title="删除" @click="handleRemove(warehouseImgs[2])"></span>
                                </div>
                            </div>
                            <div class="cert-item col-md-3 col-lg-3">
                                <div class="img-box rela-img">
                                    <img :src="warehouseImgs[3].original.url" alt="">
                                </div>
                                <div class="license-btn">
                                    <Upload type="drag" ref="upload" accept="image/*" :data="{position:3}" :action="uploadAction" :on-success="OnUploadSuccess" :on-format-error="handleFormatError" :format="['jpg','jpeg','png']" class="uploadcla">
                                        <span class="iconfont icon-cm-file" title="修改"></span>
                                    </Upload>
                                    <span class="iconfont icon-search" title="放大" @click="handleView(warehouseImgs[3])"></span>
                                    <span class="iconfont icon-dump" title="删除" @click="handleRemove(warehouseImgs[3])"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </Card>
    <Modal title="查看图片" v-model="visible" class="img-ivu-modal">
        <img :src="imgName" v-if="visible" style="width: 100%">
    </Modal>
</div>
</template>

<script>
export default {
    data() {
        return {
            value1: [],
            ressData: this.$store.state.cities,
            uploadList: [],
            imgName: "",
            visible: false,
            warehouseImgs: [{
                    original: {
                        url: "",
                        name: ""
                    }
                },
                {
                    original: {
                        url: "",
                        name: ""
                    }
                },
                {
                    original: {
                        url: "",
                        name: ""
                    }
                },
                {
                    original: {
                        url: "",
                        name: ""
                    }
                }
            ],
            uploadAction: "/api/file/upload/single",

            // disabled: false,
            loading: true,
            IsPublish: "",

            // 仓库信息发布数据绑定
            detail: {
                Province: "410000",
                City: "",
                LogCenterName: "", // 物流中心名称
                ServiceRange2: [], // 服务范围复选框
                SecuritySystem2: [], // 安保系统复选框
                FireFightingSystem2: [], // 消防系统
                GoodsCategory2: [], // 库存类别复选框
                PictContent: [],
                TotalVolume: null
            },
            LogCenterList: [],
            datas: "",
            saveDisabled: false,
        };
    },
    mounted() {
        this.detail.index = 2;
        this.detail.content = this.detail.WarehouseIntroduction;

        this.$bus.emit("showEditorModel", this.detail);
    },
    methods: {
        venue(val, txt) {
            this.detail.Venue = txt.map(c => c.label).join("/");
            this.detail.City = val[0];
            this.detail.District = val[1];
        },
        handleView(name) {
            if (!name) {
                this.$Notice.warning({
                    title: "提示",
                    desc: "未上传图片！"
                });

                return;
            }

            this.imgName = name.original.url;
            this.visible = true;
        },
        handleRemove(warehouseImg) {
            warehouseImg.original.url = "";
        },
        OnUploadSuccess(response) {
            this.warehouseImgs[response.fields.position].original.url =
                response.file.original.url;
            console.log(response);
        },
        handleBeforeUpload() {
            const check = this.uploadList.length < 2;
            if (!check) {
                this.$Notice.warning({
                    title: "最多只能上传 1 张图片。"
                });
            }
            return check;
        },
        handleMaxSize(file) {
            this.$Notice.warning({
                title: "超出文件大小限制",
                desc: "文件 " + file.name + " 太大，不能超过 2M。"
            });
        },
        handleFormatError(file) {
            this.$Notice.warning({
                title: "文件格式不正确",
                desc: "文件 " + file.name + " 格式不正确，请上传 jpg 或 png 格式的图片。"
            });
        },
        getLogCenters() {
            var self = this;
            this.axios.get("/api/warehouse/LogisticsCenters").then(function(res) {
                self.LogCenterList = res.datas;
            });
        },
        getData() {
            var self = this;

            this.axios
                .get("/api/warehouse/details/" + this.$route.params.guid)
                .then(function(res) {
                    if (!res.ServiceRange) {
                        res.ServiceRange = "[]";
                    }
                    if (!res.SecuritySystem) {
                        res.SecuritySystem = "[]";
                    }
                    if (!res.FireFightingSystem) {
                        res.FireFightingSystem = "[]";
                    }
                    if (!res.GoodsCategory) {
                        res.GoodsCategory = "[]";
                    }

                    let images = JSON.parse(res.PictContent || "[]");

                    for (let index = 0; index < 4; index++) {
                        if (images[index] && images[index].original) {
                            self.warehouseImgs[index].original.url = images[index].original.url;
                        }
                    }

                    self.value1 = [res.City, res.District];
                    self.IsPublish = res.IsPublish;

                    res.ServiceRange2 = JSON.parse(res.ServiceRange);
                    res.SecuritySystem2 = JSON.parse(res.SecuritySystem);
                    res.FireFightingSystem2 = JSON.parse(res.FireFightingSystem);
                    res.GoodsCategory2 = JSON.parse(res.GoodsCategory);
                    self.detail = res;
                    self.detail.index = 2;
                    self.detail.content = self.detail.WarehouseIntroduction;
                    self.$bus.emit("showEditorModel", self.detail);
                });
        },
        save() {
            var self = this;
            var phone = /^((13|14|15|17|18)[0-9]{1}\d{8})$/;

            if (!this.detail.ChineseName) {
                this.$Message.error("请填写仓库名称!");
                return;
            } else if (!this.detail.Contacts) {
                this.$Message.error("请填写联系人!");
                return;
            } else if (!this.detail.ContactTel) {
                this.$Message.error("请填写联系电话!");
                return;
            } else if (!phone.test(this.detail.ContactTel)) {
                this.$Message.error("手机格式不正确");
                return;
            } else if (!this.detail.TotalAreaAge) {
                this.$Message.error("请填写仓库面积!");
                return;
            } else if (!(this.detail.TotalAreaAge > 0)) {
                this.$Message.error("请输入大于零的仓库面积!");
                return;
            } else if (!this.detail.LeasingPrice) {
                this.$Message.error("请填写租赁价格!");
                return;
            }else if (!(this.detail.LeasingPrice > 0)) {
                this.$Message.error("请输入大于零的租赁价格!");
                return;
            } else if (!this.detail.Minleasedrea) {
                this.$Message.error("请填写起租面积!");
                return;
            } else if (!(this.detail.Minleasedrea > 0)) {
                this.$Message.error("请输入大于零的起租面积!");
                return;
            } else if (!this.detail.Venue) {
                this.$Message.error("请填写地址!");
                return;
            } else if (
                parseFloat(this.detail.TotalAreaAge) <
                parseFloat(this.detail.CanRentedArea)
            ) {
                this.$Message.error("仓库面积要不小于可租面积!");
                return;
            } else if (
                parseFloat(this.detail.Minleasedrea) >
                parseFloat(this.detail.CanRentedArea)
            ) {
                this.$Message.error("起租面积要小于可租面积!");
                return;
            } else if (parseFloat(this.detail.Minleasedrea) >
                parseFloat(this.detail.TotalAreaAge)) {
                this.$Message.error("起租面积要小于仓库面积!");
                return;
            }

            this.detail.PictContent = JSON.stringify(
                this.warehouseImgs.map(b => {
                    if (b.original.url) {
                        return b;
                    }

                    return null;
                })
            );

            this.detail.ServiceRange = JSON.stringify(this.detail.ServiceRange2);
            this.detail.SecuritySystem = JSON.stringify(this.detail.SecuritySystem2);
            this.detail.FireFightingSystem = JSON.stringify(
                this.detail.FireFightingSystem2
            );
            this.detail.GoodsCategory = JSON.stringify(this.detail.GoodsCategory2);

            if (this.$route.params.falg == "false") {
                this.detail.GUID = this.$route.params.guid;
            } else {
                this.detail.GUID = "";
            }

            this.saveDisabled = true;
            this.$store.commit('loading');

            this.axios.post("/api/warehouse/save", this.detail).then(function(res) {
                self.$store.commit('loading', false);

                if (!res.message) {
                    self.$Message.success("保存成功");
                    if (res.guid) {
                        self.$route.params.guid = res.guid;
                    }

                    self.$router.push("/front/warehouseEditList");
                }
            }).catch(function(res) {
                self.saveDisabled = true;
                console.log(JSON.stringify(res));
                self.$store.commit('loading', false);
                self.$Message.error("保存失败");
            });
        },
        publish: function() {
            var self = this;

            if (this.$route.params.falg == "false") {
                this.detail.GUID = this.$route.params.guid;
            } else {
                this.detail.GUID = "";
            }
            if (this.$route.params.guid == "00") {
                this.$Message.error("请先保存再发布");
                return;
            }
            this.axios
                .post("/api/warehouse/publish", {
                    GUID: this.$route.params.guid
                })
                .then(function(res) {
                    if (!res.message) {
                        self.$Message.success("发布成功");
                    }

                    self.$router.push("/front/warehouseEditList");
                });
        },
        addParagraph(editValue) {
            this.detail.WarehouseIntroduction = editValue;
        }
    },
    created() {
        this.getLogCenters();

        if (this.$route.params.falg == "false") {
            this.getData();
        }
    },
    activated() {
        this.getLogCenters();

        if (this.$route.params.falg == "false") {
            this.getData();
        }
    },
    watch: {
        detail: {
            handler: function(val, oldVal) {
                self.IsPublish = "N";
            },
            deep: true
        }
    }
};
</script>